import { request } from '../service'
import IBaseObj from '#/index'

const getFolderList = (pid: number | string) =>
  request({
    url: `/crf/folder/list?pid=${pid}`,
    method: 'GET',
  })

const createFolder = (data: IBaseObj) =>
  request({
    url: '/crf/folder/create',
    method: 'POST',
    data,
  })

const updateFolder = (data: IBaseObj) =>
  request({
    url: '/crf/folder/modify',
    method: 'POST',
    data,
  })

const createForm = (data: IBaseObj) =>
  request({
    url: '/crf/form/create',
    method: 'POST',
    data,
  })

const updateForm = (data: IBaseObj) =>
  request({
    url: '/crf/form/modify',
    method: 'POST',
    data,
  })

const queryForm = (data: IBaseObj) =>
  request({
    url: '/crf/form/query',
    method: 'POST',
    data,
  })

const saveFormItem = (data: IBaseObj) =>
  request({
    url: '/crf/form/save/item',
    method: 'POST',
    data,
  })

const getForm = (id: number | string) =>
  request({
    url: `/crf/form/${id}`,
    method: 'GET',
  })

const getJson = (url: string) =>
  request({
    url: '/file' + url,
    method: 'GET',
  })

export default {
  getFolderList,
  createFolder,
  updateFolder,
  createForm,
  updateForm,
  queryForm,
  saveFormItem,
  getForm,
  getJson,
}
